package com.jltx.xq.simplewatch.news.adapter;

import android.graphics.Color;
import android.support.annotation.Nullable;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.jltx.xq.simplewatch.R;
import com.jltx.xq.simplewatch.news.model.bean.WeChatNews;
import com.jltx.xq.simplewatch.utils.GlideUtils;

import java.util.List;

/**
 * @author jltxseo
 *         Created by junlintianxia on 2017/08/28.
 */

public class WeChatNewsAdapter extends BaseQuickAdapter<WeChatNews,BaseViewHolder> {

    public WeChatNewsAdapter(@Nullable List<WeChatNews> data) {
        super(R.layout.item_news_wechat,data);
    }

    @Override
    protected void convert(BaseViewHolder helper, WeChatNews weixinNews) {
        helper.setText(R.id.tv_description,weixinNews.getDescription());
        helper.setText(R.id.tv_title,weixinNews.getTitle());
        helper.setText(R.id.tv_time,weixinNews.getHottime());
        GlideUtils.load(mContext, weixinNews.getPicUrl(), helper.getView(R.id.iv_weixin));
        helper.addOnClickListener(R.id.btn_item_del);

        if(weixinNews.getIsRead() == 1){
            helper.setTextColor(R.id.tv_title, Color.GRAY);  //已读变灰色
        }else {
            helper.setTextColor(R.id.tv_title,Color.BLACK); //未读
        }
    }


    public void onItemRemove(int position){
        mData.remove(position);
        int internalPosition = position + getHeaderLayoutCount();
        notifyItemRemoved(internalPosition);
    }
}
